module OpenSourceProjectsHelper
  def show_condition(app_dir, language, created_time, name)
    s=''.html_safe
    unless app_dir.nil?
      s_temp = content_tag('a', app_dir)
      temp = link_to 'x', {:controller => "open_source_projects", :action => "remove_condition", :language => language, :created_time => created_time, :name => name}
      temp = content_tag('span', temp, :class => 'del')
      s_temp << temp
      s_temp = content_tag('span', s_temp, :class => 'tag_show')
      s << content_tag('div', s_temp, :id => 'tag')

    end
    unless language.nil?
      s_temp = content_tag('a', language)
      temp = link_to 'x', {:controller => "open_source_projects", :action => "remove_condition", :app_dir => app_dir, :created_time => created_time, :name => name}
      temp = content_tag('span', temp, :class => 'del')
      s_temp << temp
      s_temp = content_tag('span', s_temp, :class => 'tag_show')
      s << content_tag('div', s_temp, :id => 'tag')
    end
    unless created_time.nil?
      s_temp = content_tag('a', created_time)
      temp = link_to 'x', {:controller => "open_source_projects", :action => "remove_condition", :app_dir => app_dir, :language => language, :name => name}
      temp = content_tag('span', temp, :class => 'del')
      s_temp << temp
      s_temp = content_tag('span', s_temp, :class => 'tag_show')
      s << content_tag('div', s_temp, :id => 'tag')
    end
    s = content_tag('div', s, :id => 'tags_show')
    s = content_tag('div', s, :id => 'tags')
    s = content_tag('div', s, :class => 'user_tags')
  end

  def get_open_source_projects_by_tag(tag_name)
    OpenSourceProject.tagged_with(tag_name) #.order('created_time desc')
  end

  def show_origin(url)

  end

  def show_description(bug, open_source_project)
    description = BugToOsp.where("osp_id = ? and relative_bug_id = ?", open_source_project.id, bug.id).first.description
    if description.nil? || description == ''
      description = open_source_project.name + l(:label_bug)
    end
    description
  end

  def show_description_of_bug(bug)
    #description = BugToOsp.where("relative_bug_id = ?", bug.id).first.description
    #
    #if description.nil? || description == ''
    #  description = bug.open_source_project.name + l(:label_bug)
    #end
    #description
    desc=bug.bug_to_osps.first.description
    unless desc.blank?
      return desc
    end
    bug.open_source_projects.name
  end
end
